<!DOCTYPE html>
<html layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">

<head>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"/>

    <title th:text="#{cas.mfa.registerdevice.pagetitle}">CAS MFA Register Device View</title>
    <link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>
</head>

<body>
<main class="container mt-3 mb-3" role="main">
    <div class="mdc-card mdc-card-content w-lg-50 p-4 m-auto" id="login" layout:fragment="content">
        <h2 th:text="#{cas.mfa.registerdevice.label.title}">Register Device</h2>
        <p th:text="#{cas.mfa.registerdevice.label.intro}">Please name the current device.</p>

        <form id="registerform" method="post" th:action="@{/login}" th:object="${mfaTrustRecord}">
            <div
                    class="mdc-text-field mdc-text-field--with-trailing-icon d-flex caps-check">
                <input autocomplete="off" class="mdc-text-field__input pwd" id="deviceName" name="deviceName" size="25"
                       th:field="*{deviceName}" type="text"/>
                <label class="mdc-floating-label" for="deviceName"
                       th:utext="#{cas.mfa.registerdevice.label.name}">Name</label>
            </div>

            <div><p>How long should we remember this device?</p></div>
            <div class="d-flex mt-2">
                <div class="mdc-text-field  mr-2">
                    <input class="mdc-text-field__input" id="expiration" name="expiration"
                           th:field="*{expiration}" type="number">
                    <label class="mdc-floating-label" for="expiration">Expiration</label>
                </div>
                <select class="custom-select" id="timeUnit" name="timeUnit"
                        onchange="let hide = this.value!=='FOREVER'; $('#expiration').toggle(hide)"
                        th:field="*{timeUnit}">
                    <option value="SECONDS">Seconds</option>
                    <option value="MINUTES">Minutes</option>
                    <option value="HOURS">Hours</option>
                    <option value="DAYS">Days</option>
                    <option value="WEEKS">Weeks</option>
                    <option value="MONTHS">Months</option>
                    <option value="YEARS">Years</option>
                    <option value="FOREVER">Forever</option>
                </select>
            </div>

            <div class="d-flex mt-3">
                <button accesskey="s" class="mdc-button mdc-button--raised"
                        th:value="#{cas.mfa.registerdevice.button.register}">
                        <span class="mdc-button__label"
                              th:text="#{cas.mfa.registerdevice.button.register}">Register</span>
                </button>&nbsp;
                <button accesskey="k" class="mdc-button mdc-button--raised" name="resend"
                        th:value="#{cas.mfa.registerdevice.button.skip}">
                    <span class="mdc-button__label" th:text="#{cas.mfa.registerdevice.button.skip}">Skip</span>
                </button>
            </div>
            <input name="_eventId_submit" type="hidden" value="Register"/>
            <input name="geolocation" type="hidden"/>
            <input name="execution" th:value="${flowExecutionKey}" type="hidden"/>
        </form>
    </div>
</main>
</body>

</html>
